package com.chixing.dao.impl;

import com.chixing.dao.RowMapper;
import com.chixing.entity.Employee;

import java.sql.ResultSet;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;

public class EmployeeRowMapper implements RowMapper<Employee> {
    public Employee mapper(ResultSet rs){
        Employee emp=null;
        try {
        int empno=rs.getInt(1);
        String empname=rs.getString(2);
        String empJob=rs.getString(3);
        int managerNo=rs.getInt(4);
        Instant instant = rs.getDate(5).toInstant();
        ZoneId zoneId = ZoneId.systemDefault();
        LocalDate hiredate = instant.atZone(zoneId).toLocalDate();
        float salary=rs.getFloat(6);
        float comm=rs.getFloat(7);
        int deptNo=rs.getInt(8);
        emp=new Employee(empno,empname,empJob,managerNo,hiredate,salary,comm,deptNo);
    }catch (Exception e) {
        e.printStackTrace();
    }
        return emp;
    }

}
